import request from '@/utils/request'
import { BaseResponse } from '../base'
import { CreateOrderReq, OrderPay } from './type'

export function createOrder(data: CreateOrderReq): Promise<BaseResponse> {
  return request({ url: '/campus/goods/order/create', method: 'post', data })
}

export function payOrder(params: OrderPay): Promise<BaseResponse> {
  return request({ url: '/campus/goods/order/pay', method: 'put', params })
}

export function buyerOrderDeatil(orderNo: string): Promise<BaseResponse> {
  return request({ url: `/campus/goods/order/buyer/detail/${orderNo}`, method: 'get' })
}

export function sellerOrderDeatil(orderNo: string): Promise<BaseResponse> {
  return request({ url: `/campus/goods/order/seller/detail/${orderNo}`, method: 'get' })
}

export function confirm(orderNo: string): Promise<BaseResponse> {
  return request({ url: `/campus/goods/order/confirm/${orderNo}`, method: 'put' })
}

export function confirmDeliver(orderNo: string): Promise<BaseResponse> {
  return request({ url: `/campus/goods/order/confirmDeliver/${orderNo}`, method: 'put' })
}

export function cancel(orderNo: string): Promise<BaseResponse> {
  return request({ url: `/campus/goods/order/cancel/${orderNo}`, method: 'put' })
}

export function applyRefund(orderNo: string): Promise<BaseResponse> {
  return request({ url: `/campus/goods/order/applyRefund/${orderNo}`, method: 'put' })
}

export function cancelRefund(orderNo: string): Promise<BaseResponse> {
  return request({ url: `/campus/goods/order/cancelRefund/${orderNo}`, method: 'put' })
}

export function refund(orderNo: string): Promise<BaseResponse> {
  return request({ url: `/campus/goods/order/refund/${orderNo}`, method: 'put' })
}

export function buyerPage(params: any): Promise<BaseResponse> {
  return request({ url: '/campus/goods/order/buyer/page', method: 'get', params })
}

export function sellerPage(params: any): Promise<BaseResponse> {
  return request({ url: '/campus/goods/order/seller/page', method: 'get', params })
}

export function deleteOrder(orderNo: string): Promise<BaseResponse> {
  return request({ url: `/campus/goods/order/delete/${orderNo}`, method: 'delete' })
}

export function deleteMeOrder(orderNo: string): Promise<BaseResponse> {
  return request({ url: `/campus/goods/order/deleteMe/${orderNo}`, method: 'delete' })
}